<?php
define("JL", 1);

@session_start();
// Includes obligatorios
include './dbconfig.php';
require './administration/Libraries/JLAjax.class.php';
$id = 1;

$_txtemail = filter_var($_POST['_txtemail'], FILTER_SANITIZE_STRING);

$Ajax = JLAjax::getInstance();
$Ajax->checkToken();

if ($Ajax->isAjaxRequest()) {
    if ($Ajax->isValidToken() && !empty($_txtemail) && filter_var($_txtemail, FILTER_VALIDATE_EMAIL)) {
        include( './administration/Libraries/Tools/JLTools.class.php' );

        $_section = filter_var(trim($_POST['_section']), FILTER_SANITIZE_NUMBER_INT);
        $seccion_name = filter_var(trim($_POST['_section_name']), FILTER_SANITIZE_STRING);
        $asunto = "Formulaire de contact CSME" . (empty($seccion_name) ? "" : " - $seccion_name");

        $_genero = trim($_POST['_genero']);
        $_txtnom = trim($_POST['_txtnom']);
        $_txtprenom = trim($_POST['_txtprenom']);
        $_txtcodepostal = trim($_POST['_txtcodepostal']);
        $_txtville = trim($_POST['_txtville']);

        $_txtmessage = str_replace("\n", "<br />", trim($_POST['_txtmessage']));
        $_txtmessage = str_replace("'", "&rsquo;", trim($_txtmessage));
        $_txtmessage = str_replace(trim("\ "), "", trim($_txtmessage));

        $nombrefull = $_genero . " " . $_txtnom . " " . strtoupper($_txtprenom);
        $nombre = $_txtnom . " " . strtoupper($_txtprenom);
        if (!empty($_txtcodepostal))
            $_txtcodepostal = " - " . $_txtcodepostal;

        $ville = $_txtville . $_txtcodepostal;
        $email = $_txtemail;

        $SQL = "SELECT 
          `int_id_template`,
          `var_title_template`,
          `txt_template_html`,
          `int_id_state`
        FROM 
          `tbl_template`
        WHERE
          `int_id_template` = '1'";

        $res = mysql_query($SQL, $cnn);
        $row = mysql_fetch_assoc($res);
        $message = $row['txt_template_html'];

        $jl = JLTools::getInstance();
        $_month = array("Janvier", "F&eacute;vrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Ao&ucirc;t", "Septembre", "Octobre", "Novembre", "D&eacute;cembre");
        $_days = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche");
        $_year = date("Y");
        $fecha = "le " . $_days[intval(date("N")) - 1] . " " . date("j") . " " . $_month[intval(date("n")) - 1] . " " . $_year;

        require "./administration/Libraries/Tools/phpmailer/phpmailer.php";
        $mail = new PHPMailer();

        $mail->PluginDir = "";
        $mail->IsHTML(true);
        $mail->CharSet = "utf-8";
        $mail->IsMail();
        $mail->Timeout = 10;
        $mail->From = "system@csme.fr";
        $mail->FromName = utf8_encode("CSME Back Office");
        $mail->Subject = $asunto;

        $SQL = "SELECT 
          tbl_users.var_fullname,
          tbl_users.var_email
        FROM
          tbl_states
          INNER JOIN tbl_users ON (tbl_states.int_id_state = tbl_users.int_id_state)
        WHERE ";
        $SQL .= empty($_section) ? "tbl_users.int_id_typeuser = 1 AND tbl_users.int_id_state <> 3" : "tbl_users.int_id_typeuser = 1 OR tbl_users.int_id_section = '" . $_section . "' AND tbl_users.int_id_state <> 3";

        require dirname(__FILE__) . '/administration/Libraries/Smarty/Smarty.class.php';
        $smarty = new Smarty();
        $smarty->assign(array(
            'BASE_URL' => getNameDomain(),
            'DATE' => $fecha,
            'SECCION' => $seccion_name,
            'FULLNAME_GENDER' => $nombrefull,
            'ADDRESS' => $ville,
            'EMAIL' => $email,
            'FULLNAME' => $nombre,
            'MESSAGE' => $_txtmessage
        ));
        $mail->Body = $smarty->fetch(dirname(__FILE__) . "/images/mail/form_contact.html");

//        $message = str_replace("%SERVER%", getNameDomain(), file_get_contents('images/mail/form_contact.html'));
//        $message = str_replace("%DATE%", $fecha, $message);
//        $message = str_replace("%SECCION%", $seccion_name, $message);
//        $message = str_replace("%FULLNAME%", $nombrefull, $message);
//        $message = str_replace("%ADDRESS%", $ville, $message);
//        $message = str_replace("%EMAIL%", $email, $message);
//        $message = str_replace("%MESSAGE%", $_txtmessage, $message);
//        $mail->Body = $message;

        $res = mysql_query($SQL, $cnn);
        while ($row = mysql_fetch_assoc($res)) {
            $mails = explode(",", $row['var_email']);

            if (count($mails) > 0) {
                foreach ($mails as $v) {
                    $mail->AddAddress($row['var_fullname'] . " <" . $v . ">");
                    $exito = $mail->Send();
                    $mail->ClearAddresses();
                }
            } else {
                $mail->AddAddress($row['var_fullname'] . " <" . $row['var_email'] . ">");
                $exito = $mail->Send();
                $mail->ClearAddresses();
            }
        }

        @mysql_close($cnn);
        $Ajax->resetToken();
        $Ajax->response(RESPONSE_CODE_OK);
    } else {
        $Ajax->forbiddenHeader();
    }
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-FR" lang="fr-FR" >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="pragma" content="no-cache" />
        <meta name="robots" content="index, follow" />
        <meta name="google-site-verification" content="l6Fc4-_RGKeL_0Y8H7wAhDHge8ORqjoSkWeN2WQQzrU" />
        <meta name="generator" content="LBN | Design &amp; Development Studio" />
        <title>Contact</title>
        <link href="js/lib/flexslider.css" rel="stylesheet" type="text/css" media="screen, projection" />
        <link href="base.css" rel="stylesheet" type="text/css" media="all" />
        <link href="slider/stylesheets/slider-popup.css" rel="stylesheet" type="text/css" media="screen, projection" />
        <link href="js/lib/xpopup/xpopup-1.0.css" rel="stylesheet" type="text/css" media="screen, projection" />
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script>!window.jQuery && document.write(unescape('%3Cscript src="js/lib/jquery-1.7.1.min.js"%3E%3C/script%3E'))</script>
        <link rel="stylesheet" href="slider/stylesheets/coda-slider-2.0.css" type="text/css" media="screen" />
        <script type="text/javascript" src="slider/javascripts/jquery.coda-slider-2.0_update.js"></script>
        <script type="text/javascript" src="slider/javascripts/jquery.easing.1.3.js"></script>
        <script type="text/javascript" src="js/lib/xpopup/xpopup.min-1.0.js"></script>
        <script type="text/javascript" src="js/lib/jquery.xvalidator-1.0.min.js"></script>
        <script type="text/javascript" src="js/lib/jquery.cookie.min.js"></script>
        <script type="text/javascript" src="js/lib/utils-1.0.min.js"></script>
        <script type="text/javascript" src="js/lib/jquery.tooltip.min.js"></script>
        <script type="text/javascript" src="js/lib/jquery.flexslider-min.js"></script>
        <script type="text/javascript" src="administration/?act=required"></script>
        <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript" src="js/lib/jquery.gmap3-3.4.min.js"></script>
        <style type="text/css">
            .block { display: inline; }
            #error_chk{ display: none;  color:#C00; }	
            label.error {font-size:15px; font-weight:bold; color:#C00; display:inline;}
            #msg-error{ font-weight:bold; color:#C00; }

            a:hover.lien p.url {
                color: #00A893;
            }
        </style>
        <!--[if IE]>
        <style>.submitimagehidden{ margin-left:160px; margin-top:43px; }</style>
        <![endif]-->
        <!--[if IE 7]>
        <link href="base-ie7.css" rel="stylesheet" type="text/css" media="screen, projection" charset="utf-8" />
        <![endif]-->
        <link rel="shortcut icon" href="favicon.ico" />
        <link rel="alternate" type="application/rss+xml" title="CSME Actualitès - RSS Feed" href="http://feed.csme.fr/" />
    </head>
    <body>
        
        <?php include 'modules/annonce.html.php'; ?>

        <div id="button_top">
            <a href="javascript:;"><img src="images/arrow_top.png" width="18" height="25" />
                <span id="top">TOP <br /><strong>SITE</strong></span></a>
        </div>

        <div id="main-container">

            <input id="hdn-section" type="hidden" value="<?php
echo $newId;
?>" />
            <input id="hdn-section_name" type="hidden" value="<?php
                   echo $row['var_desc_section'];
?>" />
            <!-- BN-TOP -->
            <div id="bn-top" class="bxshd">    

                <!-- MENU-TOP -->
                <div class="menu-top">

                    <div id="logo">
                        <a href="./" title="CSME Club Sportif Multisections d'Epinay-sur-Seine"><img alt="CSME LOGO" src="images/csme-logo.png" width="174" height="159" /></a>
                    </div>

                    <!-- NEWSLETTER -->
                    <div id="newsletter" class="bxshd">
                        <div class="newscenter">
                            <div class="newscontent">
                                <h3><img src="images/sobre.png" width="16" height="12" /> Newsletter</h3>
                                <div class="subtitle">Inscrivez-vous à notre newsletter.</div>
                                <div><form action="./" method="post" enctype="application/x-www-form-urlencoded" name="frmnewsletter" id="frmnewsletter">
                                        <input name="txtnom" type="text" class="txtnewsletter" id="txtnom" autocomplete="off" />
                                        <label id="email">
                                            <input name="txtemail" type="text" class="txtnewsletter" id="txtemail" autocomplete="off" />
                                            <input class="valid" type="submit" value="OK" onfocus="this.blur();" />
                                        </label>
                                    </form>
                                </div>



                                <div id="partenaires">

                                    <div class="face_fb_plugin"><a title="Suivez-nous sur facebook" target="_blank" href="http://www.facebook.com/CSMEpinaysurSeine"></a></div>
                                    <div class="text_fb_plugin">Soyez le premier parmi vos amis.
                                        <br />Rejoignez-nous vite !
                                    </div>
                                    <div class="fb_like_plugin">
                                        <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FCSME-Club-Sportif-Multisections-dEpinay-sur-Seine%2F176399182395742&amp;layout=button_count&amp;locale=fr_FR&amp;show_faces=false&amp;width=170&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:170px; height:21px;" allowTransparency="true"></iframe>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- END NEWSLETTER -->


                    <!-- MENU -->
                    <ul>
                        <li><a class="link" title="Accueil" href="./"  target="_parent">Accueil</a></li>
                        <li><a class="link" title="Présentation" href="presentation.html"  target="_parent">Présentation</a></li>
                        <li><a class="link" title="Les sections" target="_parent" id="les_sections_id">Les sections</a>

                            <?php
                            include_once 'modules/menu.html.php';
                            printMenu($select);
                            ?>
                        </li>
                        <li><a class="link" title="Actualités" href="actualites.html" target="_parent">Actu. CSME</a></li>
                        <li><a class="link" title="Administration" href="administration.html" target="_parent">Administration</a></li>
                        <li><a class="link selected" title="Contact" href="contacts.html" target="_parent">Contact</a></li>
                    </ul>
                    <!-- END MENU-->


                </div>
                <!-- END MENU-TOP -->


            </div>
            <!-- END BN-TOP -->


            <!-- BN-CONTENT-->
            <div id="bn-content">

                <!-- BN CONTENT TEXT -->
                <div class="bn-content-text bxshd">
                    <div class="bn-ct-top"></div>
                    <table border="0" cellpadding="0" cellspacing="0" class="bn-ct-repeat">
                        <tr>
                            <td class="bn-ct-r-center">
                                <div class="bn-ct-r-center-menu">
                                    <div class="bn-menu-title">
                                        <div class="bn-menu-icon"></div>
                                        <h1 title="Contact">Contact</h1>
                                    </div>
                                </div>

                                <div class="coda-slider preload" id="coda-slider-1">

                                    <div class="panel">
                                        <div class="panel-wrapper">
                                            <h2 class="title">Ecrivez-nous<div class="sub-line title"></div></h2>

                                            <div class="bn-contact">
                                                <form id="frm-contact" name="frm-contact" method="post" action="./" enctype="application/x-www-form-urlencoded">
                                                    <table class="bn-c-form" border="0" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td align="center" valign="top" colspan="3" height="25"><strong id="msg-error"></strong></td>
                                                        </tr>
                                                        <tr>
                                                            <td width="166" align="right" valign="top">* Civilité:</td>
                                                            <td width="20"><input type="hidden" id="txtvalido" /></td>
                                                            <td width="324">
                                                                <label>
                                                                    <input type="radio" value="Mlle." name="gender" id="rdo_mlle" validate="required:true" /> 
                                                                    Mlle </label>
                                                                <label>
                                                                    <input type="radio" value="Mme." name="gender" id="rdo_mme" /> 
                                                                    Mme </label>
                                                                <label>
                                                                    <input type="radio" value="M." name="gender" id="rdo_m" /> 
                                                                    M.&nbsp;<label id="error_chk" for="gender" class="error">*</label>
                                                                </label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right"></td>
                                                            <td width="20">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" valign="top">* Nom :</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td><input name="txtnom" type="text" class="text" id="txtnom2" value=""  /></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" valign="top">* Prénom :</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td><input name="txtprenom" type="text" class="text" id="txtprenom" value="" />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" valign="top">Code Postal :</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td><input name="txtcodepostal" type="text" class="text" id="txtcodepostal" value="" /></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" valign="top">Ville :</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td><input name="txtville" type="text" class="text" id="txtville" value="" /></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>

                                                            <td align="right" valign="top">* Adresse e-mail :</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td><input name="txtemail2" type="text" class="text" id="txtemail2" value="" autocomplete="off" /> 
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" valign="top" class="txtarea">* Votre message :</td>
                                                            <td width="20">&nbsp;</td>
                                                            <td rowspan="2" valign="top"><textarea class="text" name="txtmsg" id="txtmsg"></textarea></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td width="20">&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                            <td><input size="45" type="submit" value="Envoyer" class="button" /></td>
                                                        </tr>
                                                    </table>
                                                </form>




                                                <div class="bn-c-right">
                                                    <div class="bn-c-right-reseig">RENSEIGNEMENTS:</div>
                                                    <?php
                                                    $SQL = "SELECT 
                              `int_id_contact_csme`,
                              `var_cont_nom`,
                              `var_cont_status`,
                              `var_cont_tel`,
                              `var_cont_email`,
                              `int_id_state`
                            FROM 
                              `tbl_contact_csme`
                            WHERE `int_id_state` <> 3";

                                                    $res5 = mysql_query($SQL, $cnn);
                                                    $tt = mysql_num_rows($res5);
                                                    $i = 1;
                                                    while ($row5 = mysql_fetch_assoc($res5)) {
                                                        ?><strong><?php echo $row5['var_cont_nom']; ?></strong><br />
                                                        <em><?php echo $row5['var_cont_status']; ?></em><br />
                                                        Tel. <?php echo $row5['var_cont_tel']; ?><br />
                                                        <a href="mailto:<?php echo $row5['var_cont_email']; ?>"><?php echo $row5['var_cont_email']; ?></a>
                                                        <?php if ($i < $tt) { ?>
                                                            <div class="sub-line"></div>
                                                            <?php
                                                        }
                                                        $i++;
                                                    }
                                                    ?>
                                                </div>



                                            </div>

                                        </div>



                                        <div class="panel">

                                            <div class="panel-wrapper">

                                                <h2 class="title">

                                                    Accès<div class="sub-line title"></div>

                                                </h2>



                                                <!--GOOGLE MAP -->

                                                <table class="ct-googlemap"  border="0" align="left" cellpadding="0" cellspacing="0">

                                                    <tr>

                                                        <td>

                                                            <div id="map" class="section-map"></div>

                                                        </td>

                                                        <td valign="top">

                                                            <a id="map-1" class="click map">

                                                                <img src="markers/image01.png" width="36" height="53" /><br />
                                                                <strong> CSME</strong><br />
                                                                6 av. de Lattre Tassigny<br />
                                                                Epinay-sur-Seine 93800
                                                            </a>

                                                            <div class="sub-line map"></div>

                                                            <a id="map-2" class="click map last">
                                                                <img src="markers/image02.png" width="36" height="53" /><br />
                                                                <strong>Mairie Epinay-sur-Seine</strong><br />
                                                                1-3 rue Quétigny<br />
                                                                Epinay-sur-Seine 93800
                                                            </a>
                                                            <div class="sub-line map"></div>
                                                        </td>

                                                    </tr>

                                                </table>

                                                <!-- END GOOGLE MAP -->



                                            </div>

                                        </div>



                                        <div class="panel">

                                            <div class="panel-wrapper">

                                                <h2 class="title">

                                                    Liens<div class="sub-line title"></div></h2>

                                                <?php
                                                $SQL = "SELECT 
                              `int_id_lien_csme`,
                              `var_lien_title`,
                              `var_lin_link`,
                              `int_id_state`
                            FROM 
                              `tbl_liens_csme`
                            WHERE `int_id_state` <> 3";

                                                $res6 = mysql_query($SQL, $cnn);
                                                $tt = mysql_num_rows($res6);
                                                $ii = 1;
                                                while ($row6 = mysql_fetch_assoc($res6)) {
                                                    ?>
                                                    <a class="lien" href="<?php echo $row6['var_lin_link']; ?>" target="_blank">
                                                        <p class="sub-lien"><strong><?php echo $row6['var_lien_title']; ?></strong></p>
                                                        <p class="url"><?php echo $row6['var_lin_link']; ?></p>
                                                        <?php if ($ii < $tt) { ?>
                                                            <div class="sub-line2 lien"></div></a>
                                                        <?php
                                                    }
                                                }
                                                ?>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <div class="fldbtm"></div>                    
                </div>
                <!-- END CONTENT TEXT -->

                <div id="push"></div>

            </div>    
            <!-- BN-CONTENT-->
        </div>

        <?php
        include 'modules/footer.html.php';
        printFooter($cnn, $select);
        printTooltips($cnn);
        ?>

        <script type="text/javascript" src="js/js-main.js"></script>
        <script type="text/javascript" src="js/js-contact.js"></script>
        <script type="text/javascript" src="js/js-contact-map.js"></script>

        <?php
        printMyVisites();
        @mysql_close();
        ?>
    </body>
</html>